﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace Business_Layer
{
    [Serializable]
    public class Relation : Component
    {
        public Relation(Component component1, Component component2, string text)
            : base(component1.Position.X, component1.Position.Y, component2.Position.X, component2.Position.Y, text)
        {
            colorBehaviour = new NotColorable();

            this.component1 = component1;
            this.component2 = component2;
        }

        private Component component1;
        public Component Component1
        {
            get { return component1; }
        }

        private Component component2;
        public Component Component2
        {
            get { return component2; }
        }

        /// <summary>
        /// Returns the alternate string.
        /// </summary>
        public override string AlternateString
        {
            get { return null; }
            set { AlternateString = null; }
        }

        /// <summary>
        /// Changes the color of this component.
        /// </summary>
        /// <param name="color"></param>
        public override void ChangeColor(Color color)
        {
            colorBehaviour.SetColor(color);
        }

        /// <summary>
        /// Draws this component onto a Graphics object.
        /// </summary>
        /// <param name="g">Graphics object.</param>
        /// <returns></returns>
        public override Graphics Draw(Graphics g)
        {
            sx = component1.Position.X;
            sy = component1.Position.Y;
            ex = component2.Position.X;
            ey = component2.Position.Y;

            g.DrawLine(new Pen(colorBehaviour.GetColor()), sx, sy, ex, ey);
            return g;
        }

        /// <summary>
        /// Moves this component into a specified direction. (Does nothing for relations, these are solid relationships).
        /// </summary>
        /// <param name="dx">Direction X.</param>
        /// <param name="dy">Direction Y.</param>
        public override void Move(int dx, int dy)
        {
            // Do nothing. This is a solid relationship.
        }
    }
}
